﻿Imports System.ExecutorServices
Imports System.Runtime.CompilerServices
Imports System.Aspect

Namespace Data.Objects

    Public Module Product

        <Item("Product", "product")> Public Interface IProduct
            <Field("ProductID", "product id")> Property ProductID() As Integer
        End Interface

        Public Interface IProductInfo
            Inherits IProduct
            <Field("ProductName", "product name")> Property ProductName() As String
        End Interface

        Public GetNew As dcGetNew = Aspect(Of dcGetNew)()
        <DataCall("AddANewProduct", "add a new product")> Public Delegate Function dcGetNew( _
        <Field("ProductName", "product name")> ByVal ProductName As String) As IProductInfo

        Public GetAll As dcGetAll = Aspect(Of dcGetAll)()
        <DataCall("GetAllProducts", "get all products")> Public Delegate Function dcGetAll() As IProductInfo()

        <Extension()> _
        Public Sub DeleteThisProduct(ByVal p As IProduct)
            _dcDeleteProduct(p.ProductID)
        End Sub

        Private _dcDeleteProduct As dcDelete = Aspect(Of dcDelete)()
        <DataCall("DeleteProduct", "delete a product")> Private Delegate Sub dcDelete( _
        <Field("ProductID", "product id")> ByVal ProductID As Integer)

    End Module

End Namespace